package www.core.com.service.impl;

import javax.annotation.Resource;

import org.apache.lucene.queryParser.ParseException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import www.core.com.dao.BaseDAO;
import www.core.com.pojo.Message;
import www.core.com.pojo.Topic;
import www.core.com.pojo.TopicContent;
import www.core.com.pojo.User;
import www.core.com.service.ITopicService;
import www.core.com.utils.Page;

@RestController
@Service("topicService")
@Transactional
public class TopicServiceImpl implements ITopicService {

	@Resource(name = "hibernateDAO")
	BaseDAO<Object> hibernateDAO;
	public Message<Topic> detail(Topic topic) {
		return null;
	}
	@RequestMapping("test")
	public Message<Topic> add(Topic topic, TopicContent detail,User user) throws InterruptedException {
		// TODO Auto-generated method stub
//		topic.setUser(user);
		hibernateDAO.save(topic);
		detail.setTopic(topic);
		hibernateDAO.executeSearch(detail);
		
		return null;
	}
	@RequestMapping("testsearch")
	public Page testsearch(String search) throws ParseException {
		// TODO Auto-generated method stub
//		topic.setUser(user);
//		hibernateDAO.getSearch(Topic.class, 1,search, "title","content");
		
		return hibernateDAO.getSearch(TopicContent.class, 1,search, "title","content");
	}
}
